package org.agony2d.gpu.supportClasses.buffers {
	import flash.display3D.IndexBuffer3D;
	import flash.display3D.VertexBuffer3D;
	
	import org.agony2d.core.agony_internal;
	import org.agony2d.gpu.core.AAManager;
	
	use namespace agony_internal;
	
public class BuffersProp {
	
	[Inline]
	final agony_internal function uploadData( maxNodes:int ) : void {
		if(maxNodes > m_maxNodes){
			if(m_vb3d){
				m_vb3d.dispose()
				m_ib3d.dispose()
			}
			m_vb3d = AAManager.g_context3d.createVertexBuffer(maxNodes * 4, 5)
			m_ib3d = AAManager.g_context3d.createIndexBuffer(maxNodes * 6)
			m_maxNodes = maxNodes
		}
		
		m_vb3d.uploadFromByteArray(BuffersManager.g_bytes, 0, 0, maxNodes * 4)
		m_ib3d.uploadFromVector(BuffersManager.g_indexList, 0, maxNodes * 6)
	}
	
	[Inline]
	final agony_internal function resetData( maxNodes:int ) : void {
		m_vb3d = AAManager.g_context3d.createVertexBuffer(maxNodes * 4, 5)
		m_ib3d = AAManager.g_context3d.createIndexBuffer(maxNodes * 6)
		m_maxNodes = maxNodes
	}
	
	agony_internal static const NUM_VERTEX_PER_NODE:int = 4
	agony_internal static const NUM_INDEX_PER_NODE:int = 6
	
	agony_internal var m_ib3d:IndexBuffer3D
	agony_internal var m_vb3d:VertexBuffer3D
	agony_internal var m_maxNodes:int
}
}